<?php

class Antz_Form_Components_DateSelect_Select extends Antz_Form_Component
{
    protected $options = array();
    protected $type = 'DateSelect_Select';

    public function __construct($name, $value=''){
        $this->id = 'sel'.rand();
        $this->name = $name;
        $this->value = $value;
    }

    public function add($title, $value=''){
        if($value=='')$value = $title;
        $selected = ($this->value.'' == ''.$value) ? true : false;
        $this->options[] = Antz::newObject('Antz_Form_Components_Option', array($title, $value, $selected));
        return $this->options[(count($this->options)-1)];
    }

    public function render(){
        $disabled = ($this->disabled) ? 'disabled="disabled"' : '';
        $returnString = "\n".'<select name="'.$this->name.'" id="'.$this->getId().'" '.$this->renderParameters().$disabled.'>';
        foreach($this->options as $option){
            $returnString .= "\n  ".$option->render();
        };
        $returnString .= "\n".'</select>'.$this->afterText;
        return $returnString;
    }
}
